 
/*  
  function linkGoodsOpr_t()
  {
             var size =document.getElementById("chechsize").value;
             var type =document.getElementById("type").value;             
             var innerHTMLStr = "";
             var link_goods="";
             var k=1;            
             for(var i=0;i<size;i++)
             {
                 if(document.getElementById('chechGoodsId'+i).checked)
                 {
                   var goods_id = document.getElementById('chechGoodsId'+i).value;
                   link_goods += goods_id+"|";
                                    
                   var goods_name = document.getElementById('chechGoodsName'+i).value;
                   innerHTMLStr +="<tr><td width='5%' height='35' align='right' style='background:#F9F9F9;'><font color='#666666'>"+
								                  k+":</font>"+			  
								                  "</td><td width='55%' style='background:#F9F9F9;'><font color='#666666'>"+goods_name+"</font></td>"+
					                        "<td width='40%'></td></tr>";
                    k++;                 
                 }             
             } 
            
             if(type=='g')
             {             
               document.getElementById("link_goods").value = link_goods;
             }
             if(type=='p')
             {             
               document.getElementById("link_fit").value = link_goods;
             } 
             
           	 document.getElementById(type+"_goods_table").innerHTML= "<table width='100%' border='0' cellspacing='0' cellpadding='0' >"         	 
           	                                                          + innerHTMLStr+ "</table>";
             TB_remove();          
  }
 */
    
var globalVal = '';
function linkGoodsOpr()
{
		 var size =document.getElementById("listsize").value;
		 var innerHTMLStr = "";
		 var link_goods = "";
		 var k = 1;    
		 var type =document.getElementById("type").value;         
		 for(var i=0;i<size;i++)
		 {
		     if(document.getElementById('checkone'+i).checked)
		     {
			       var goods_id = document.getElementById('checkone'+i).value;
			       link_goods += goods_id + "|";
			       var goods_name = document.getElementById('chechGoodsName'+i).value;
			       setDivHtml(type,k,goods_name,goods_id);
			       innerHTMLStr += globalVal;
			       k++;
		     }             
		 } 
		 if(type=='g')
     {             
        document.getElementById("link_goods").value = link_goods;
     }
     if(type=='p')
     {             
        document.getElementById("link_fit").value = link_goods;
     } 
		 
		 document.getElementById(type+"_goods_table").innerHTML= "<table width='100%' border='0' cellspacing='0' cellpadding='0' >" + innerHTMLStr + "</table>";
		 TB_remove();
}

function setDivHtml(type,k,goods_name,goods_id)
{
    globalVal = "<tr id='"+type+"_spandiv"+k+"'><td width='5%' height='35' align='right' style='background:#F9F9F9;'><font color='#666666'>"+k+":</font>"+"</td><td width='55%' style='background:#F9F9F9;'><font color='#666666'>"+goods_name+"</font></td>"+"<td width='40%'>&nbsp;<img src='/program/company/index/images/cross.png' style='vertical-align:middle;cursor:pointer;' title=移除关联 onclick=moveout('"+type+"','"+k+"','"+goods_id+"') /></td></tr>";
}

function moveout(type,k,goods_id)
{
		if(type=='g')
     {             
        var link_goods = document.getElementById("link_goods").value;
        link_goods = link_goods.replace(goods_id+'|','');
        document.getElementById("link_goods").value = link_goods;    
     }
     if(type=='p')
     {             
        var link_fit = document.getElementById("link_fit").value;
        link_fit =link_fit.replace(goods_id+'|','');
        document.getElementById("link_fit").value = link_fit;  
     } 
		 document.getElementById(type+"_spandiv"+k).style.display='none';
}    
    
    